package com.yuhanginfo.modules.web.util;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.yuhanginfo.common.utils.ReadProperties;
/**
 * 短信接口调用
 */

public class SmsMobile {
	private SmsMobile(){}
	public static final Logger LOG =  LoggerFactory.getLogger(SmsMobile.class);
	
	public static void sendMessage(String phone,String tplId,String tplValue){  //改为静态
		Map<String, String> str=new HashMap<String,String>();
		str.put("key", ReadProperties.ReadByName("SMS_KEY"));
		str.put("mobile", phone);
		str.put("tpl_id", tplId);
		str.put("tpl_value",tplValue);
	 	String message=HttpPost.sendPost(ReadProperties.ReadByName("SMS_URL"), str);
	 	LOG.info(message);
	}
	
    public static void writeToWeb(String message, String type, HttpServletResponse response) throws IOException{
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setContentType("text/" + type +"; charset=utf-8");
        response.getWriter().write(message);
        response.getWriter().close();
    }
}
